package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.SchoolbagBooksDO;
import com.starlink.model.request.SchoolbagBooksRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface SchoolbagBooksMapper extends BaseMapper<SchoolbagBooksDO> {
    SchoolbagBooksDO selectDOById(Long id);
    List<SchoolbagBooksDO> selectDOList(SchoolbagBooksDO schoolbagBooks);
    int insertDO(SchoolbagBooksDO schoolbagBooks);
    int batchInsertDO(List<SchoolbagBooksDO> schoolbagBooksDOList);
    int updateDO(SchoolbagBooksDO schoolbagBooks);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from schoolbag_books",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") SchoolbagBooksRequest param);
    @Select({"<script>",
            "   select * from schoolbag_books",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<SchoolbagBooksDO> pageQuery(@Param("param") SchoolbagBooksRequest param, @Param("limit") int limit, @Param("offset") long offset);

    List<SchoolbagBooksDO> listQuery(SchoolbagBooksRequest request);
}
